<?php
/**
 * Author: Artem Azarov <bel-azar@ya.ru>
 * Date: 2/25/12
 * Time: 12:20 AM
 */
class Controller extends CController
{
	/**
	 * @var string the default layout for the controller view. Defaults to '//layouts/column1',
	 * meaning using a single column layout. See 'protected/views/layouts/column1.php'.
	 */
	public $layout='/layouts/main';
	/**
	 * @var array context menu items. This property will be assigned to {@link CMenu::items}.
	 */
	public $menu=array();
	/**
	 * @var array the breadcrumbs of the current page. The value of this property will
	 * be assigned to {@link CBreadcrumbs::links}. Please refer to {@link CBreadcrumbs::links}
	 * for more details on how to specify this property.
	 */
	public $breadcrumbs=array();

    public function init()
    {
        parent::init();

        if (($langCode = Yii::app()->getRequest()->getParam('lang', false)) ||
            ($langCode = (isset(Yii::app()->getRequest()->cookies['lang'])
                ? Yii::app()->getRequest()->cookies['lang']->value
                : false))) {

            Yii::app()->setLanguage($langCode);
            //set lang cookie expr time in year
            Yii::app()->getRequest()->cookies['lang'] = new CHttpCookie('lang', $langCode, array('expire'=>31104000));
        }
        Yii::app()->getClientScript()->registerCoreScript('jquery');
    }
}
